﻿// Cancel default behavior
function doBeforePaste(obj) {
    if (!isNaN(obj.getAttribute("TAMaxLength")))
        event.returnValue = false;
}
// Cancel default behavior and create a new paste routine
function doPaste(obj) {
    if (!isNaN(obj.getAttribute("TAMaxLength"))) {
        event.returnValue = false;
        maxLength = parseInt(obj.getAttribute("TAMaxLength"));
        var iInsertLength = maxLength - obj.value.length;
        var sData = window.clipboardData.getData("Text").substr(0, iInsertLength);
        obj.value = obj.value + sData;
    }
}